package com.aibili.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.aibili.pojo.UserLocation;

@Service("userLocationService")
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public class UserLocationService extends BaseService {

	/**
	 * 
	 * @Description 新增用户地理位置信息
	 * @param location
	 */
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public void add(UserLocation location) {
		dataDao.addObject(location);
	}

	/**
	 * 
	 * @Description 修改用户地理位置信息
	 * @param location
	 */
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
	public void update(UserLocation location) {
		dataDao.updateObject(location);
	}

	/**
	 * 
	 * @Description 查找用户位置信息
	 * @param user_id
	 * @return
	 */
	public UserLocation getByUserid(long user_id) {
		String hql = " from UserLocation where user_id = :user_id";
		UserLocation location = null;
		location = (UserLocation) dataDao.getFirstObjectViaParam(hql, new String[] { "user_id" }, user_id);
		return location;
	}

}
